package com.poizon.vo;

import com.poizon.config.SystemConfig;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName R
 * @Author NoCheng
 * @Date 2022/1/2 9:59
 * @Description:TODO 发送至前端的结果类
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {

    private int code;
    private String msg;
    private Object data;

    public static R createR(int code,String msg,Object data){
        return new R(code, msg, data);
    }

    public static R ok(String msg,Object data){
        return createR(SystemConfig.R_OK,msg,data);
    }
    public static R ok(Object data){
        return createR(SystemConfig.R_OK,"OK",data);
    }
    public static R ok(){
        return createR(SystemConfig.R_OK,"OK",null);
    }
    public static R fail(String msg){
        return createR(SystemConfig.R_FAIL, msg ,null);
    }
}
